<!--评价学员-->
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="主班老师" prop="teacher">
        <el-select
          v-model="queryParams.teacher"
          placeholder="请选择主班老师"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="item in teacherList"
            :key="item.value"
            :label="
              !item.isJob
                ? item.label + '(已离职)'
                : !item.isTeacher
                ? item.label + '(非授课)'
                : item.label
            "
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="助教老师" prop="assistant">
        <el-select
          v-model="queryParams.assistant"
          placeholder="请选择助教老师"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="item in teacherList"
            :key="item.value"
            :label="
              !item.isJob
                ? item.label + '(已离职)'
                : !item.isTeacher
                ? item.label + '(非授课)'
                : item.label
            "
            :value="item.value"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item label="所在班级" prop="classId">
        <el-select
          v-model="queryParams.classId"
          placeholder="请选择所在班级"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="item in classList"
            :key="item.id"
            :label="item.beOver === '0' ? item.name + '(已结业)' : item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="评分" prop="tstate">
        <el-select
          v-model="queryParams.tstate"
          placeholder="请选择评分"
          clearable
          style="width: 240px"
        >
          <el-option v-for="n in 5" :key="n" :label="n + '分'" :value="n" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">
          搜索
        </el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList">
      </right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="list" border>
      <el-table-column label="评价时间" align="center" prop="createDate" />
      <el-table-column label="主班老师" align="center" prop="teacherName" />
      <el-table-column label="班级名称" align="center" prop="className" />
      <el-table-column label="上课时间" align="center" prop="classDate" />
      <!-- <el-table-column label="助教老师" align="center" prop="assistantName" /> -->
      <el-table-column label="学员姓名" align="center" prop="studentName" />
      <el-table-column label="评价内容" align="center" prop="description" />
      <el-table-column label="评分" align="center" prop="tstate">
        <template #default="scope"> {{ scope.row.tstate }}分 </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="CommentStudent">
import { getPeopleList } from "@/api/studentManagement/index.js";
import { getClassListAPI } from "@/api/registrar/class";
import { getEvaluateTeacherListAPI } from "@/api/interaction/comment";

const { proxy } = getCurrentInstance();
const loading = ref(false);
const showSearch = ref(true);
const total = ref(0);

const list = ref([]);
const teacherList = ref([]);
const classList = ref([]);

const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    classId: "",
    teacher: null,
    // assistant: null,
    // classStartTime: null,
    // classEndTime: null,
    tstate: null,
  },
});

const { queryParams } = toRefs(data);

// 事件-----------------------------------------------------------------------------------------------------------

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  queryParams.value = {
    pageNum: 1,
    pageSize: 10,
    classId: "",
    teacher: null,
    // assistant: null,
    // classStartTime: null,
    // classEndTime: null,
    tstate: null,
  };
  getList();
}

// 方法-----------------------------------------------------------------------------------------------------------
// 获取教师列表
function getTeacherList() {
  loading.value = true;
  getPeopleList({ isTeach: 1 }).then((response) => {
    teacherList.value = response.data;
    loading.value = false;
  });
}

// 班级
function getClassList() {
  loading.value = true;
  getClassListAPI({ pageSize: 9999, pageNum: 1 }).then((response) => {
    classList.value = response.rows;
    loading.value = false;
  });
}

// 列表查询
function getList() {
  loading.value = true;
  getEvaluateTeacherListAPI(proxy.addDateRange(queryParams.value, [])).then(
    (response) => {
      list.value = response.rows;
      total.value = response.total;
      loading.value = false;
    }
  );
}

// 初始化-------------------------------------------------------------------------------------------------------
getTeacherList();
getClassList();
getList();
</script>

<style lang="scss" scoped></style>
